Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls


Partial Class Poll_Manage
    Inherits System.Web.UI.Page

    Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs)
        If e.Values.Item("PollId") Is Nothing Then
            e.Values.Item("PollId") = Guid.NewGuid()
        End If

        If String.IsNullOrEmpty(e.Values.Item("Question").ToString()) Then
            e.Values.Item("Question") = "Vraag?"
        End If

        If e.Values("CreationDate") Is Nothing Then
            e.Values.Item("CreationDate") = DateTime.Now
        End If

        If e.Values.Item("memberid") Is Nothing Then
            e.Values.Item("memberid") = DirectCast(Membership.GetUser().ProviderUserKey, Guid)
        End If
    End Sub

    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
        If String.IsNullOrEmpty(e.NewValues.Item("Question").ToString()) Then
            e.NewValues.Item("Question") = "Vraag?"
        End If

        e.NewValues.Item("CreationDate") = Convert.ToDateTime(e.NewValues.Item("CreationDate"))
    End Sub

End Class
